﻿@model Model.tb_Sample
@{
    Layout = null;
}

<!DOCTYPE html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title>样品管理</title>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/default/easyui.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/icon.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/demo.css")'>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/uploader/uploadify.css")' />
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/jquery.easyui.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/jquery.uploadify.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/swfobject.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftMvcAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")'></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dgtable').datagrid({
                url: "/Sample/GetSampleList",
                pagination: true,//分页控件  
                singleSelect: true,//是否单选
                rownumbers: true,
                queryParams: { 'pageNumber': 1, 'pageSize': 15, '_searchtext': "", '_searchtype': "", '_cid': '@ViewBag._lid' },
                columns: [[
                    { field: 'sampleNum', title: '样品编号', width: 100, align: 'center' },
                    { field: 'name', title: '样品名称', width: 100, align: 'center' },
                    { field: 'protNum', title: '产品批次', width: 100, align: 'center' },
                    {
                        field: 'productDate', title: '生产日期', width: 80, align: 'center',
                        formatter: function (value, row, index) {
                            if (value == undefined || value.length < 9) {
                                return "";
                            }
                            value = value.substr(0, value.length - 8);
                            return value;
                        }
                    },
                    {
                        field: 'isDetection', title: '抽样形式', width: 80, align: 'center',
                        formatter: function (value, row, index) {
                            return row.isDetection == "True" ? "抽样" : "送样";
                        }
                    },
                    {
                        field: 'detectionDate', title: '送/抽样日期', width: 120, align: 'center',
                        formatter: function (value, row, index) {
                            if (value == undefined || value.length < 9) {
                                return "";
                            }
                            value = value.substr(0, value.length - 8);
                            return value;
                        }
                    },
                    { field: 'detectionUser', title: '抽样者', width: 80, align: 'center' },
                    { field: 'batch', title: '样品数量', width: 80, align: 'center' },
                    { field: 'packaging', title: '包装方式', width: 80, align: 'center' },
                    { field: 'expirationDate', title: '保质期', width: 80, align: 'center' },
                    { field: 'modelType', title: '规格型号', width: 80, align: 'center' },
                    //{ field: 'detectionGist', title: '抽样依据', width: 80, align: 'center' },
                    //{ field: 'detectionMethod', title: '抽样方法', width: 80, align: 'center' },
                    { field: 'detectionAdress', title: '抽样地点', width: 80, align: 'center' },
                    { field: 'detectionCompany', title: '抽样单位', width: 80, align: 'center' },
                    { field: 'InspectCompany', title: '送样单位', width: 80, align: 'center' },
                    { field: 'InspectAddress', title: '送样地址', width: 80, align: 'center' },
                    //{ field: 'projectName', title: '项目名称', width: 80, align: 'center' },
                    //{ field: 'testMethod', title: '检验方法', width: 80, align: 'center' },
                    { field: 'sampleAdmin', title: '样品管理员', width: 80, align: 'center' },
                    { field: 'handleUser', title: '销毁人', width: 80, align: 'center' },
                    {
                        field: 'handleDate', title: '销毁时间', width: 120, align: 'center',
                        formatter: function (value, row, index) {
                            if (value == undefined || value.length < 9) {
                                return "";
                            }
                            value = value.substr(0, value.length - 8);
                            return value;
                        }
                    },
                    {
                        field: 'Edit', title: '编辑', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            var url = '@Url.Action("doSampleInfo", "Sample")' + "?id=" + row.id;
                            return "<a href='" + url + "' target='mainFrame' ><img width='18px' height='18' alt='修改' src='../../Content/Images/xiugai.png' /></a>";
                        }
                    },
                    {
                        field: 'Delete', title: '删除', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            var linkstr = "<a href=\"javascript:void(0)\" onclick=\"click_Delete(" + row.id + ")\" ><img width='18px' height='18' alt=\"删除\" src=\"../../Content/Images/shanchu.png\" /></a>";
                            return linkstr;
                        }
                    },
                    {
                        field: 'Destroy', title: '销毁', width: 40, align: 'center',
                        formatter: function (value, row, index) {
                            var linkstr = "<a href=\"javascript:void(0)\" onclick=\"click_Destroy(" + row.id + ")\" ><img width='18px' height='18' alt=\"销毁\" src=\"../../Content/Images/xiugai.png\" /></a>";
                            return linkstr;
                        }
                    }
                ]],
                onLoadSuccess: function (data) {
                    var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
                    var _search = tablequeryParams._searchtext;
                    var _searchtype = tablequeryParams._searchtype;
                    var _companyid = tablequeryParams._cid;
                    var url = '@Url.Action("Export_Sample", "Sample")' + "?_search=" + _search + "&_searchtype=" + _searchtype + "&_companyid=" + _companyid;
                    $("#exportExcel").attr("href", url);
                }
            });
            var p = $('#dgtable').datagrid('getPager');
            $(p).pagination({
                pageSize: 15,//每页显示的记录条数，默认为10  
                pageList: [10, 15, 20],//可以设置每页记录条数的列表  
                onSelectPage: function (pageNumber, pageSize) {
                    var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
                    tablequeryParams.pageNumber = pageNumber;
                    tablequeryParams.pageSize = pageSize;
                    $('#dgtable').datagrid('options').queryParams = tablequeryParams;
                    $("#dgtable").datagrid("reload");
                }
            });
            $('#dlg').dialog('close');
            $('#dlg_detection').dialog('close');
            $("#span_date").hide();
            $('#ddl_search').change(function () {
                var ddl = $(this).children('option:selected').val();
                if (ddl == "抽样日期") {
                    $('#txt_Search1').attr("onfocus", 'WdatePicker({ maxDate: "#F{$dp.$D(\'txt_Search2\')||\'2100-10-01\'}"})');
                    $('#txt_Search2').focus(function () { WdatePicker({ minDate: '#F{$dp.$D(\'txt_Search\')}', maxDate: '2100-10-01' }) });
                    $("#span_date").show("normal");
                    $('#txt_Search').hide();
                } else {
                    $('#txt_Search').show();
                    $("#span_date").hide("normal");
                }
            });
        });

                function click_Detection(_itemId) {
                    window.frames["doDetectionfm"].location = '@Url.Action("doDetectionInfo", "Sample")' + "?_sid=" + _itemId;
            $('#dlg_detection').dialog('open');
        }

        function click_Delete(_itemId) {
            if (confirm("确定要删除数据吗？")) {
                $.getJSON("/Sample/Delete_Item/" + _itemId, function (data) { alert(data); if (data == "删除成功！") { $('#dgtable').datagrid('reload'); } });
            }
        }

        function click_Destroy(_itemId) {
            if (confirm("确定要销毁吗？")) {
                $.getJSON("/Sample/Destroy_Item/" + _itemId, function (data) { alert(data); if (data == "销毁成功！") { $('#dgtable').datagrid('reload'); } });
            }
        } 

        function click_Search() {
            var ddls = $("#ddl_search").val();
            var txts = $("#txt_Search").val();
            var _cid = $('#ddlcompany').val();
            if (ddls == "抽样日期") {
                txts = $("#txt_Search1").val();
                var txt2 = $("#txt_Search2").val();
                if (txt2 == null || txt2 == "") {
                    return;
                }
                txts += "," + txt2;
            }
            var tablequeryParams = $('#dgtable').datagrid('options').queryParams;
            tablequeryParams._searchtype = ddls;
            tablequeryParams._searchtext = txts;
            if (_cid > 0) {
                tablequeryParams._cid = _cid;
            }
            $('#dgtable').datagrid('options').queryParams = tablequeryParams;
            $("#dgtable").datagrid("reload");
        }

        function click_Stander(_itemId)
        {
            window.parent.mainFrame.location.href = '@Url.Action("doTestStanderd", "Sample")' + "?_sampleId=" + _itemId;
        }
    </script>
    <style type="text/css">
        .divList {
            position: absolute;
            top: 40px;
            left: 1px;
            z-index: 99;
            width: 1048px;
        }

        a {
            text-decoration: none;
            color: #000;
        }

            a img {
                border: 0;
            }

        .biaoge {
            width: 1040px;
            font-family: '宋体';
            font-size: 12px;
            color: #10607c;
        }

            .biaoge td {
                text-align: center;
                height: 26px;
                vertical-align: middle;
                border: 1px solid #d4d3d3;
            }
    </style>
</head>
<body style="background-color: transparent; overflow: auto;">
    <!--新增-->
    <div id="dlg" class="easyui-dialog" title="样品管理" data-options="iconCls:'icon-save'" style="width: 620px; height: 390px; padding: 0px; position: absolute; z-index: 999; left: 5px;">
        <iframe style="overflow-x: scroll; overflow-y: hidden; border: 0; height: 350px; width: 600px;" name="doCUfm"></iframe>
    </div>
    <div id="dlg_detection" class="easyui-dialog" title="抽样情况" data-options="iconCls:'icon-save'" style="width: 620px; height: 390px; padding: 0px; position: absolute; z-index: 999; left: 5px;">
        <iframe style="overflow-x: scroll; overflow-y: hidden; border: 0; height: 350px; width: 600px;" name="doDetectionfm"></iframe>
    </div>
    <!--End 新增-->


    <div style="background: #faf1e8; height: 30px; width: 100%; top: 1px; position: absolute; z-index: 99; left: 1px;">
        <table align="left" width="100%" height="27px">
            <tr>
                <td width="1029" style="font-family: '宋体'; font-size: 12px; color: #10607c;">当前位置：样品管理<img style="text-align:center;vertical-align:middle;height:10px" src='@Url.Content("~/Content/Images/位置.png")' />样品管理 </td>
            </tr>
        </table>
    </div>

    <div class="divList">
        <table cellpadding="0" cellspacing="0" width="1040px">
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" width="1040px">
                        <tr>
                            <td width="200px" style="font-family: '宋体'; font-size: 12px; color: #10607c;">单位：
                                @if ((Session["UserInfo"] as Model.PersonnelManage.E_tb_InPersonnel).DataRange == 1)
                                {
                                    @Html.DropDownList("ddl_company", ViewData["ddl_company"] as SelectList, new { @id = "ddlcompany" })
                                }
                                else
                                { 
                                    @Html.DropDownList("ddl_company", ViewData["ddl_company"] as SelectList, new { @id = "ddlcompany", @disabled = "disabled" })
                                }
                            </td>
                            <td width="130px" style="font-family: '宋体'; font-size: 12px; color: #10607c;">按：      
                                    <select id="ddl_search">
                                        <option value="样品名称">样品名称</option>
                                        <option value="样品人">抽样人</option>
                                        <option value="抽样日期">抽样日期</option>
                                    </select>
                            </td>
                            <td >
                                <input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search" />
                                <span id="span_date" style="font-family: '宋体'; font-size: 12px;">
                                    <input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search1" />
                                    至
                                <input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search2" />
                                </span>
                            </td>
                            <td width="160px">
                                <a href="javascript:void(0)" onclick="click_Search()">
                                    <img height="20px" src='@Url.Content("~/Content/Images/chaxun.png")' /></a>
                                <a href='@Url.Action("doSampleInfo", "Sample", new { @id = 0 })' target='mainFrame' >
                                    <img src='@Url.Content("~/Content/Images/xinzeng.png")' height="20px" /></a>
                            </td>
                            <td align="right">
                                <a href='javascrpt:void(0)' target='mainFrame' id="exportExcel">
                                    <img src='@Url.Content("~/Content/Images/导出Excel.png")' /></a>
                                @*<a href="javascript:void(0)" onclick="click_Edit(0)">
                                    <img src='@Url.Content("~/Content/Images/xinzeng.png")' height="20px" /></a>
                                <a href="javascript:history.go(-1)" target="mainframe">
                                    <img src="../../Content/Images/fanhui.png" height="20px" /></a>*@
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table cellpadding="0" cellspacing="0" class="biaoge" id="dgtable" height="400px">
                    </table>
                </td>
            </tr>
        </table>
    </div>
</body>
